package erlwitch.tree;

import java.util.ArrayList;
import java.util.List;

public class ErlangList extends Term {
	private List<Term> terms;
	private Term rest;
	
	public ErlangList(int begin, int end, Term rest) {
		super(begin, end);
		this.rest = rest;
	}
	public ErlangList(int begin, int end, List<Term> terms, Term rest) {
		super(begin, end);
		this.rest = rest;
	}
	public ErlangList(int begin, int end, List<Term> terms) {
		super(begin, end);
		this.terms = terms;
	}
	public ErlangList(int begin, int end) {
		super(begin, end);
	}
	public List<Term> getTerms() {
		return terms;
	}
	public void setTerms(List<Term> terms) {
		this.terms = terms;
	}
	public Term getRest() {
		return rest;
	}
	public void setRest(Term rest) {
		this.rest = rest;
	}
	public void addFirst(Term e) {
		if (terms == null) terms = new ArrayList<Term>();
		terms.add(0, e);
	}
	public void setBegin(int begin) {
		this.begin = begin;
	}
	public String toString() {
		return "ErlangList " + (terms != null?""+terms.size():"0") + (rest != null?rest.toString():"");
	}
}
